from base import mysqlConnect, getRequestContentLength
import re

def getPicUrl():
    sum = 0
    picnum = 0
    db, cursor = mysqlConnect.connect("dev1", "tiku")
    sql = "SELECT content FROM qbank_jyeoo_question"
    cursor.execute(sql)
    results = cursor.fetchall()
    for row in results:
        imgurlObj = re.search(r'src="(.+?)"', str(row))
        if imgurlObj:
            imgurl = imgurlObj.group()[5:-1]
            picsize = getRequestContentLength.get(imgurl)
            sum = sum + int(picsize)
            picnum = picnum + 1
            print(imgurl, sum, picnum)
    return sum, picnum




